class Solution {
public:
    int def(int max_num, int min_num)
    {
        if (min_num == 1) return max_num;

        min_num--;
        return max_num + def(max_num, min_num);
    }

    int multiply(int A, int B)
    {

        int max_num = max(A, B);
        int min_num = min(A, B);

        return def(max_num, min_num);
    }
};